package com.aurora.source.authority.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.aurora.source.R;
import com.aurora.source.authority.bean.SysAuthDataBean;
import com.aurora.source.base.BaseRecyclerAdapter;
import com.aurora.source.base.CommonHolder;

import butterknife.BindView;

/**
 * @author: ww
 * @description: 权限选择
 * @date: 2018/9/10
 */
public class SysAuthSelectAdapter extends BaseRecyclerAdapter<SysAuthDataBean.SystemRoleDTOListBean> {
    @Override
    public CommonHolder<SysAuthDataBean.SystemRoleDTOListBean> setViewHolder(ViewGroup parent) {
        return new MyHolder(parent.getContext(), parent);
    }

     class MyHolder extends CommonHolder<SysAuthDataBean.SystemRoleDTOListBean> {

        @BindView(R.id.tv_tag)
        TextView tvTag;

        public MyHolder(Context context, ViewGroup root) {
            super(context, root, R.layout.item_auth_select);
        }

        @Override
        public void bindData(SysAuthDataBean.SystemRoleDTOListBean addJurisdictionBean, int positon) {
            tvTag.setSelected(addJurisdictionBean.isSelect());
            tvTag.setText(addJurisdictionBean.getSysRoleName());
            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    getData(getLayoutPosition()).setSelect(!getData(getLayoutPosition()).isSelect());
                    notifyDataSetChanged();
                    if(onItemClickListener!=null){
                        onItemClickListener.onClick(getLayoutPosition(),getData(getLayoutPosition()));
                    }
                }
            });
        }
    }
}